using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;

using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Actions;
using DevExpress.ExpressApp.PivotChart;
using DevExpress.ExpressApp.PivotChart.Win;
using DevExpress.Persistent.Base;
using DevExpress.XtraPivotGrid;

namespace TransLogger.Module.Win.Controllers
{
    public partial class DateIntervalViewController : AnalysisViewControllerBase
    {
        public DateIntervalViewController()
        {
            InitializeComponent();
            RegisterActions(components);
            TargetViewId = "Analysis_DetailView";
        }

        protected override void OnActivated()
        {
            base.OnActivated();
            Frame.GetController<AnalysisDataBindController>().BindDataAction.Execute += BindDataActionOnExecute;
        }

        private void BindDataActionOnExecute(object sender, SimpleActionExecuteEventArgs simpleActionExecuteEventArgs)
        {
            if (analysisEditor != null)
            {
                PivotGridControl pivotGridControl = ((AnalysisControlWin)analysisEditor.Control).PivotGrid;
                PivotGridField fieldDate = pivotGridControl.Fields["CheckTime"];
                if (fieldDate != null)
                {
                    //fieldDate.GroupInterval = PivotGroupInterval.Hour;
                }

            }
        }

        protected override void OnDeactivated()
        {
            base.OnDeactivated();
            Frame.GetController<AnalysisDataBindController>().BindDataAction.Execute -= BindDataActionOnExecute;
        }
    }
}
